﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Globalization;

using CE.Global;
using CE.Configuration;
public partial class home : System.Web.UI.Page
{
    protected override void InitializeCulture()
    {
        String selectedCulture = CE.Global.General.SetCulture();
        base.InitializeCulture();
    }

    string selectedLanguage;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadTitles();
            //ibtnLanguage.OnClientClick = "javascript:return confirm('" + Resources.CarInsurance.LanguageChangeMessage + "');";
        }
    }
    
    protected void ibtnLanguage_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        selectedLanguage = string.Empty;

        if (hdnLanguage.Value != string.Empty)
        {
            Session["Language"] = hdnLanguage.Value;
        }

        if (Session["Language"] != null)
        {
            selectedLanguage = Session["Language"].ToString();
        }
        else
        {
            selectedLanguage = "th-TH";
            Session["Language"] = selectedLanguage;
        }

        if (selectedLanguage == "th-TH")
        {
            Session["Language"] = "en-US";
            this.divLanguage.Attributes.Add("class", "flag-th");
        }
        else
        {
            Session["Language"] = "th-TH";
            this.divLanguage.Attributes.Add("class", "flag-en");
        }

        hdnLanguage.Value = selectedLanguage;

        Response.Redirect(Request.UrlReferrer.AbsoluteUri);
    }

    private void LoadTitles()
    {
        lblTitle.Text = Resources.CarMenu.ThaiCarInsurance;
        lblCompareService.Text = Resources.CarMenu.CompareToday;
        lblLowPremium.Text = Resources.CarMenu.Lowest;
        lblInsurer.Text = Resources.CarMenu.MotorInsurer;
        lblMoneyBack.Text = Resources.CarMenu.IconMoneyBack;
        lblGetQuote.Text = Resources.CarMenu.GetaQuote;
        ibtnLanguage.ImageUrl = Resources.CarMenu.ButtonLanguageUrl;
        imgOIC.ImageUrl = Resources.CarMenu.OICUrl;
        imgDBD.ImageUrl = Resources.CarMenu.DBDUrl;
    }

}
